#-------------------------------------------------------------------------------
# Name:        模块1
# Purpose:
#
# Author:      sy
#
# Created:
# Copyright:   (c) sy
# Licence:     <your licence>
#-------------------------------------------------------------------------------
# coding: utf-8
#
##1、分别在在相机预览界面和录像预览界面点击前后摄像头切换图标 ,重复次数不低于1000次
##2、在相机预览界面，拍摄一张相片,再点击摄像头切换图标切换到另一摄像头拍摄一张相片，重复次数不低于1000次
##3、在录像预览界面，点击拍摄一段视频，再点击摄像头切换图标切换到另一摄像头拍摄一段视频
##，来回切换拍摄，重复次数不低于1000次。
##import uiautomator2 as u2

#d = u2.connect()


import sys
import os
import time
import power_button as power1

w = power1.power_1



with open("and_sn.txt", "r") as f:
    and_sn = f.readline()
    print(and_sn)

##d = u2.connect("{}".format(and_sn))
##if __name__ == '__main__':
##    d = u2.connect()


f.close()

##if len(sys.argv) == 1:
##    w.devices_connect
##else:
##    for i in range(1, len(sys.argv)):
##
##        w.devices_connect(sys.argv[i])


#test 1.1
def test1_1(cishu):

    for i in range(1, cishu):
        os.system("adb -s {} wait-for-device".format(and_sn))
        print("重启，第{}轮".format(i))
        w.reboot_9()
        time.sleep(10)
        os.system("adb -s {} wait-for-device".format(and_sn))
        time.sleep(40)


if len(sys.argv) == 1:
    test1_1(1001)
    #print("1000")
elif len(sys.argv) == 2:
    cishu = int(sys.argv[1])
    test1_1(cishu + 1)
    #print(cishu)
else:
    print("参数太多了，")





